from api.login import Login
'''商家接口'''

class MerchantProduct(Login):
    def product_save(self,name):
        '''上架商品接口'''
        data = {
            'method': 'POST',
            'url': '/api/admin/merchant/product/save',
            'headers' : {'authori-zation': self.merchant_token, 'content-type': 'application/json', },
            'json': {
                'image': 'https://javacrmeb.oss-cn-chengdu.aliyuncs.com/crmebimage/public/store/2023/11/11/365291adc2d045308fdca0a3d021a368cvgkxu1z3h.png',
                'sliderImages': [
                    'https://javacrmeb.oss-cn-chengdu.aliyuncs.com/crmebimage/public/store/2023/11/11/365291adc2d045308fdca0a3d021a368cvgkxu1z3h.png',
                ],
                'sliderImage': '["https://javacrmeb.oss-cn-chengdu.aliyuncs.com/crmebimage/public/store/2023/11/11/365291adc2d045308fdca0a3d021a368cvgkxu1z3h.png"]',
                'name': name,
                'intro': '毛衣',
                'keyword': '毛衣',
                'cateIds': [
                    151,
                ],
                'cateId': '151',
                'unitName': '华为',
                'sort': 1,
                'isShow': False,
                'tempId': 139,
                'attrValue': [
                    {
                        'image': 'https://javacrmeb.oss-cn-chengdu.aliyuncs.com/crmebimage/public/store/2023/11/11/365291adc2d045308fdca0a3d021a368cvgkxu1z3h.png',
                        'price': 0.01,
                        'vipPrice': 0.01,
                        'cost': 0.01,
                        'otPrice': 0.01,
                        'stock': 1,
                        'barCode': '',
                        'weight': 0.01,
                        'volume': 0.01,
                        'brokerage': 0,
                        'brokerageTwo': 0,
                        'cdkeyId': None,
                        'cdkeyLibraryName': '',
                        'expand': '',
                        'attrValue': '{"规格":"默认"}',
                        'productId': 0,
                    },
                ],
                'attr': [
                    {
                        'attrName': '规格',
                        'attrValues': '默认',
                        'id': 0,
                    },
                ],
                'selectRule': '',
                'isSub': False,
                'isPaidMember': False,
                'content': '',
                'specType': False,
                'couponIds': [],
                'coupons': [],
                'categoryId': 169,
                'guaranteeIds': '6,4,3',
                'guaranteeIdsList': [
                    6,
                    4,
                    3,
                ],
                'brandId': 6,
                'type': 0,
                'isAutoSubmitAudit': False,
                'isAutoUp': True,
            }
        }
        return self.send_merchant_reuqest(data)


    def product_list(self,type = 1):
        '''商品查询接口'''
        data = {
            'method': 'GET',
            'url': '/api/admin/merchant/product/list',
            'headers' : {'authori-zation': self.merchant_token,},
            'params' : {
                'page': '1',
                'limit': '20',
                'cateId': '',
                'keywords': '%E6%AF%9B%E8%A1%A3',
                'type': type,
                'temp': '1719905277',
            }
            }
        return self.send_merchant_reuqest(data)



if __name__ == '__main__':
    print(MerchantProduct().product_list().json())